import {bus} from "../@beshell/events-ts/bus"
import * as lvgl  from "../../../lvgl"


const WidgetLib = {
    Obj: {
        class: lvgl.Obj ,
        title: "矩形"
    } ,
    Label: {
        class: lvgl.Label ,
        title: "文本"
    } ,
    Bar: {
        class: lvgl.Bar ,
        title: "进度条"
    } ,
    Btn: {
        class: lvgl.Btn ,
        title: "按钮"
     } ,
     Slider: {
         class: lvgl.Slider ,
         title: "滑块"
     } ,
     Arc: {
         class: lvgl.Arc ,
         title: "弧型滑块"
     } ,
     Checkbox: {
         class: lvgl.Checkbox ,
         title: "选择框"
     } ,
     Switch: {
         class: lvgl.Switch ,
         title: "开关"
     } ,
     Dropdown: {
         class: lvgl.Dropdown ,
         title: "下拉菜单"
     } ,
     Roller: {
         class: lvgl.Roller ,
         title: "滚动菜单"
     } ,
     Line: {
         class: lvgl.Line ,
         title: "直线"
     } ,
     TextArea: {
         class: lvgl.TextArea ,
         title: "输入框"
     } ,
}

// Canvas
// MsgBox, 
// Keyboard, 
// TileView, 
// List

; (WidgetLib.Btn as any).class.prototype.forwordEvent = function() {
    this.on("click", ()=>{
        bus.emit("uiwidget.button.up", (this as any).id)
    })
    this.on("press-down", ()=>{
        bus.emit("uiwidget.button.down", (this as any).id)
    })
}

// ; (Widgets.Rocker as any).class.prototype.forwordEvent = function() {
//     this.on("input", ()=>{
//         bus.emit("uiwidget.rocker.input", this.id, this.valueX(), -this.valueY())
//     })
//     this.on("release", ()=>{
//         bus.emit("uiwidget.rocker.release", this.id)
//     })
// }

; (WidgetLib.Slider as any).class.prototype.forwordEvent = function() {
    this.on("input", ()=>{
        bus.emit("uiwidget.slider.input", this.id, this.value())
    })
    this.on("release", ()=>{
        bus.emit("uiwidget.slider.release", this.id, this.value())
    })
}

export default WidgetLib